/*
 * Copyright 2004-2011 Paolo Conte
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.jellylab.ojoverse.data;

import org.jellylab.ojoverse.Column;
import org.jellylab.ojoverse.DataObject;
import org.jellylab.ojoverse.DataWrapper;
import org.jellylab.ojoverse.types.Fieldtypes;
import org.jellylab.ojoverse.types.Keytypes;

public class Items extends DataWrapper {
    public Items() {
        column(new Column("name1", "NAME1", group("ITEMS"), varchar(255), Keytypes.DESCRIPTION, Fieldtypes.UNDEFINED));
        column(new Column("name2", "NAME2", group("ITEMS"),  varchar(255)));
        column(new Column("typeID", "FKTYPE", group("ITEMS"), bigint()));
        column(new Column("typeDesc", "DESCR", group("TYPES"), varchar(255)));
        label("name1", "Primary name");
        label("name2", "Secondary name");
        label("typeID", "Type ID");
        label("typeDesc", "Type Description");
    }

    public class ItemData extends DataObject {
        public String name1;
        public String name2;
        public Long typeID;
        public String typeDesc;
    }

    public DataObject getData() {
        return new ItemData();
    }

    public DataObject getWhere() {
        return new ItemData();
    }

    public String getSelectSQL() {
        return "SELECT NAME1, NAME2, FKTYPE, DESCR FROM ITEMS LEFT JOIN TYPES ON FKTYPE = TYPES.PKID";
    }
}
